package org.jhub1.system.xmpp.commands;

public class ReturnMessage {
	public static final int SUCCEEDED = 0;
	public static final int FAILED = 1;
	public static final int REJECTED = 2;
	public static final int REFUSED = 3;
	private String command;
	private String message;
	private String jid;
	private int eStatus = SUCCEEDED;
	private boolean status = true;
	
	public ReturnMessage(RequestMessage rm) {
		this.jid = rm.getJid();
		this.command = rm.getCommand();
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public String getJid() {
		return jid;
	}
	public int getExtStatus() {
		return eStatus;
	}
	public void setExtStatus(int eStatus) {
		this.eStatus = eStatus;
		if(eStatus != ReturnMessage.SUCCEEDED) {
			this.status = false;
		}
	}
	public String toString() {
		return "";
	}
	public boolean isStatus() {
		return status;
	}
	public void setStatus(boolean status) {
		this.status = status;
	}
	public String getStatusString() {
		String name = null;
		switch(eStatus) {
		case ReturnMessage.SUCCEEDED:
			name = "SUCCEEDED";
			break;
		case ReturnMessage.FAILED:
			name = "FAILED";
			break;
		case ReturnMessage.REJECTED:
			name = "REJECTED";
			break;
		case ReturnMessage.REFUSED:
			name = "REFUSED";
			break;	
		}
		return name;
	}
	public String getLogMessage() {
		return "User: " + this.jid + " requested: '" + this.command + "' result: " + this.getStatusString();
	}
}
